using NUnit.Framework;
using SQLLog4net.Log;
using SQLRunnerLib.Services;
using SQLServices.Log;
using SQLTests.Framework;

namespace SQLTests.Log4net.Log
{
	/// <summary>
	/// Summary description for EventLoggerTest.
	/// </summary>
	public class EventLoggerTest:
		AbstractTest
	{
	    private IEventLogger EventLogger
		{
            get { return ServiceContainer.Instance.EventLogger; }
		}

		[TestFixtureSetUp]
		protected override void SetUpFixtures()
		{
			EventLogger.DefaultPath = new PathItem(@"C:\", null);
			EventLogger.AddOk("OK Test");
			EventLogger.AddError("Error Test", "Error msg");
		}

		[Test]
		public void BasicTest()
		{
		
			Assert.AreEqual(EventLogger.TotalErrors(), 1);
			Assert.AreEqual(EventLogger.TotalScripts(), 2);	
		}

		[Test]
		public void GetError()
		{
			IItemLog item = (IItemLog) (EventLogger.Events(true)[0]);
			Assert.AreEqual(item.Type, EventType.ERROR);
			Assert.AreEqual(item.Name, "Error Test");
			Assert.AreEqual(item.Error, "Error msg");
			Assert.AreEqual(item.Path.FullPath(), @"C:\");
		}
	}
}
